import QS from 'qs'
// 测试登录
// const Loin = 'http://192.168.10.150:9100/nn-system'
export const api = {
	login: '/sys/user/login',
	logout: 'sys/user/logout', //退出登录
	getUserInfo: 'sys/user/info',
	refreshToken: 'sys/user/refresh', //刷新token
	/* uploadFile: 'file/upload', //文件上传返回url
	previewFile: 'file/preview', //图片-视频预览 */
	uploadFile: 'sys/upload', //文件上传返回url

	///wx/uploadSingle
	previewFile: '/sys/preview', //图片-视频预览
	getMd5PassIsNull: '/sys/user/getMd5PassIsNull', //获取用户是否有md5密码
	getQrCode: '/sys/wxQrCode/getQrCode', //获取登录二维码
	getLoginState: '/sys/wxQrCode/getLoginState', //查询登录状态
	sendWx: '/sys/transfer/sendWx', //发送消息到小程序
	delVerify: '/sys/user/delVerify', //校验md5 密码
	setDelVerify: '/sys/user/setDelVerify', //设置删除时候是否需要校验密码
}
export function getapi() {
	return api
}
export const sysManageapi = {
	orgUrl: {
		/* 查询机构 */
		getList: '/sys/org/page',
		/* 查询所有机构 */
		getAllList: '/sys/org/list',
		/* 新增机构 */
		add: '/sys/org/insert',
		/* 编辑机构 */
		edit: '/sys/org/update',
		/* 删除机构 */
		delete: '/sys/org/delete',
		upLoginCache: '/sys/org/upLoginCache',
		getSubjectCodeByOrg: '/sys/org/getSubjectCodeByOrg', //查询机构的所有科目
	},
	/* 角色 */
	roleUrl: {
		/* 获取所有角色 */
		getAllList: '/sys/role/list',
		/* 获取角色 */
		getList: '/sys/role/page',
		add: '/sys/role/insert',
		edit: '/sys/role/update',
		delete: '/sys/role/delete',
		setRoleDept: '/sys/role/setRoleDept',
		setRoleMenu: '/sys/role/setRoleMenu',
		setRoleUser: '/sys/role/setRoleUser',
		roleByMenu: '/sys/role/roleByMenu',
		roleByDept: '/sys/role/roleByDept',
		getBindUser: '/sys/role/bind', //获取角色关联账户
		cleRoleUser: '/sys/role/cleRoleUser'
	},
	/** 数据字典 **/
	dictUrl: {
		getList: '/sys/dict/page',
		add: '/sys/dict/insert',
		edit: '/sys/dict/update',
		delete: '/sys/dict/delete',
		/* 字典详情 */
		getItemList: '/sys/dict/item/page',
		/* 新增字典数据项 */
		addItem: '/sys/dict/item/insert',
		/* 编辑字典数据项 */
		editItem: '/sys/dict/item/update',
		/* 删除字典数据项 */
		deleteItem: '/sys/dict/item/delete',
		/*获取字典项下拉*/
		getDictItemKeyList: '/sys/dict/getDictByItem'
	},
	deptUrl: {
		getList: '/sys/dept/list',
		//getDeptlist:  '/sys/dept/page',
		getDeptList: '/sys/dept/listByAuth',
		add: '/sys/dept/insert',
		edit: '/sys/dept/update',
		delete: '/sys/dept/delete',
		getRegion: '/sys/xzqh/list',
	},
	menuUrl: {
		getList: '/sys/menu/list',
		add: '/sys/menu/insert',
		edit: '/sys/menu/update',
		delete: '/sys/menu/delete',
	},
	userUrl: {
		getList: '/sys/user/page',
		/* 新增用户 */
		add: '/sys/user/insert',
		/* 修改用户信息 */
		edit: '/sys/user/update',
		delete: '/sys/user/delete',
		setUserRole: '/sys/user/setUserRole',
		/* 修改用户密码 */
		changePwd: '/sys/user/updatePass',
		/* 重置密码 */
		resetPwd: '/sys/user/resetPass',
		/* 新——修改用户信息 */
		updateInfo: '/sys/user/updateInfo',
		/* 设置用户机构 */
		setUserOrg: '/sys/user/setUserOrg'

	},

	minimenuUrl: {
		getList: '/sys/menuWc/list',
		add: '/sys/menuWc/insert',
		edit: '/sys/menuWc/update',
		delete: '/sys/menuWc/delete',

	},
	/*************年级**************/
	gradeUrl: {
		getList: '/sys/grade/page',
		getAllList: '/sys/grade/list',
		add: '/sys/grade/insert',
		edit: '/sys/grade/update',
		delete: '/sys/grade/delete',
		detail: '/sys/grade/detail',
	},
	/*************班级**************/
	classUrl: {
		getList: '/sys/class/page',
		getAllList: '/sys/class/list',
		add: '/sys/class/insert',
		edit: '/sys/class/update',
		delete: '/sys/class/delete',
		detail: '/sys/class/detail',
		getclassOnline: '/sys/class/online', //获取在线状态
		updateByVersion: '/sys/class/updateByVersion', //用于更新有线硬件版本
		getAllClassAndReciverList: '/sys/class/getLists', //获取老师能看班级包含接收器信息

	},
	/*************科目**************/
	subjectUrl: {
		getList: '/sys/subject/page',
		getAllList: '/sys/subject/list',
		add: '/sys/subject/insert',
		edit: '/sys/subject/update',
		delete: '/sys/subject/delete',
		detail: '/sys/subject/detail',
	},
	/*************教师**************/
	teacherUrl: {
		getList: '/sys/teacher/page',
		getAllList: '/sys/teacher/list',
		add: '/sys/teacher/insert',
		edit: '/sys/teacher/update',
		delete: '/sys/teacher/delete',
		detail: '/sys/teacher/detail',
		getTeachSubjectList: '/sys/teacher/getTeachSubject', //查询权限能看到的科目
		getAddTestQuestSubject: '/sys/teacher/getAddTestQuestSubject', //新增试题时，获取老师(班主任)所带科目
		getTeacherTopPage: '/sys/teacher/getTeacherTopPage', //获取最小权限的科目
		importTeacher: '/sys/teacher/upload', //导入老师
		getTeacherInfo: '/sys/teacher/loginDetail', //上课后获取老师信息
	},
	/*************学生**************/
	studentUrl: {
		getList: '/sys/student/page',
		add: '/sys/student/insert',
		edit: '/sys/student/update',
		delete: '/sys/student/delete',
		bindStudent: '/sys/student/bindStudent', //无线绑定学生指令下发
		importStudent: '/sys/student/upload', //导入学生
		bindUpdateStudent: '/sys/student/bindUpdateStudent', //学生和答题器绑定

	},
	/*************试题**************/
	testquestUrl: {
		getList: '/sys/testquest/page',
		add: '/sys/testquest/insert',
		edit: '/sys/testquest/update',
		delete: '/sys/testquest/delete',
		detail: '/sys/testquest/detail',
		importAnswer: '/sys/testquest/upload',
		getTempList: '/sys/testquest/pagetmp', //获取临时题试卷
		insertTmp: '/sys/testquest/insertTmp', //新增临时题
		getTemplastOne: '/sys/winSendTopic/getTopicsByCsId', //获取临时题试题
		updateTempTopic: '/sys/winSendTopic/topicUpdate', //主要用于更新答案
		getRePullTestQuestId: '/sys/topic/getRePullTestQuestId', //查询可以重收得课后作业
		execTempPaiming: '/sys/topic/execTempPaiming', //重新计算临时题

	},
	/*************学年*************/
	gradeyearUrl: {
		getList: '/sys/gradeyear/list'
	},

	/*******答题***********/
	answerUrl: {
		getStuList: '/sys/student/studentbyclass', //学生名单
		getHistoryStuList: '/sys/student/studentbymongo', //获取历史学生名单
		sendTestPaper: '/sys/topic/sendTestPaper', //开始答题
		stopAnswer: '/sys/winSendTopic/stopAnswer', //停止答题
		getAnswerRecLisList: '/sys/answerRec/list', //根据发题ID答题结果
		// /netty/bind/studToMachine
		getSdTestQuestId: '/sys/sendTestQuest/findOne', //获取发题ID
		getClassStatebyTest: '/sys/testquest/classState', //根据试卷类型查询班级发题状态
		sendTempTestPaper: '/sys/winSendTopic/sendTopic', //发送临时题
		getTempAnswerRecLisList: '/sys/tempAnswer/list', //临时题-根据发题ID答题结果
		getSysTime: '/sys/time/syncTime', //获取系统时间
		startRead: '/sys/bingcard/startRead', //读卡
		endRead: '/sys/bingcard/endRead', //停止读卡
		getTempstat: '/sys/winTempstat/getWinTempStat', //获取临时题统计
		homeworkUpdateStart: '/sys/topic/homeworkUpdateStart', //收取家庭作业
		startBindCard: '/sys/bingcard/startBindCard', //刷卡绑定学生
		getfindOnes: '/sys/sendTestQuest/findOnes', //获取主观题和客观题发题ID
		findWxConnected: '/wx/course/isWwConnected', //查询是否有小程序连入课程
		startSignIn: '/sys/signIn/startSignIn', //开始签到
		endSignIn: '/sys/signIn/endSignIn', //结束签到
		getSignInInfoById: '/sys/signIn/findById', //查询签到记录
		findLastSignIn: '/sys/signIn/findLastSignIn', //查询最后一次签到记录
		startFeedback: '/sys/feedback/startFeedback', //开始反馈
		endFeedback: '/sys/feedback/endFeedback', //结束反馈
		getFeedbackInfoById: '/sys/feedback/findById', //根据id查询反馈记录
		findShareByCsId: '/sys/share/findAllByCsId', //查询分享图片
		addScore: '/sys/pingscore/add', //表扬评分
		getScoreList: '/sys/pingscore/findLasts', //查询表扬列表
		addGroup: '/sys/group/add',
		getGroupList: '/sys/group/findById',
		uploadGroup: '/sys/group/upload',
		downGroupTempl: '/sys/group/downGroupTempl',
		addOpr: '/sys/tongji/addOpr', //互动教学操作埋点
		tongjiVoice: '/sys/similarty/winVoiceSendQuest', //语音题统计
		sendtext: '/sys/book/addJob', //发送课文
		queryJobReaded: '/sys/book/queryJobReaded', //查询阅读结果
		cptongjiVoice: '/sys/similarty/wintongjiVoice', //测评统计


	},
	/*******报表统计***********/
	reportUrl: {
		getReportData: '/sys/tstReport/getReportData',
		getGroupReportData: '/sys/group/getReportData', //分组统计
	},
	/*******家长***********/
	schpatriarchUrl: {
		getList: '/sys/schpatriarch/page',
		add: '/sys/schpatriarch/insert',
		edit: '/sys/schpatriarch/update',
		delete: '/sys/schpatriarch/delete',
	},
	exportUrl: {
		downClassReport: '/sys/schexcel/downGradeReport', //导出班级报告
		downZhuGuanTi: '/sys/excel/downZhuGuanTi', //下载主观题
		uploadzg: '/sys/excel/uploadzg', //导入主观分
		downClassReportGK: '/sys/schexcel/downClassReportGK', //导出年级报告
		downSumReport: '/sys/schexcel/downSumReport', //导出月考报告
	},
	uploadUrl: {
		getLastest: '/sys/winUpgrade/queryLastest',
	},
	/*******课程***********/
	courseUrl: {
		startClass: '/sys/wincourse/attend', //开始上课
		endClass: '/sys/wincourse/finish', //下课
		findCourseOne: '/sys/course/findOne', //获取课程历史
	},
	uploadWiredUrl: {
		setWlList: '/sys/class/setWlList', //同步设备信息
		clearWl: '/sys/student/clearWl', //清空白名单
		updateWlCard: '/sys/student/updateWlCard', //有线学生绑卡
		answerUpdate: '/sys/answerRec/answerUpdate', //同步答题记录到后端


	},
	/* 意见反馈 */
	feedbackUrl: {
		getList: '/sys/wxFeedback/getFeedback'
	},

	bookUrl: {
		add: '/sys/book/addContent',
		getList: '/sys/book/query', //课程分页
	}
}
export const dashboardapi = {
	schmessageboard: {
		basemessage: '/sys/schmessageboard/basemessage',
		schdataoverview: '/sys/schmessageboard/schdataoverview', //月数据概览
		sendQueType: '/sys/schmessageboard/sendQueType', //发题类型
		sendQueTeacherSort: '/sys/schmessageboard/sendQueTeacherSort', //老师排行榜
		sendQueClassSort: '/sys/schmessageboard/sendQueClassSort', //班级排行榜
		sendQueSubCodeSort: '/sys/schmessageboard/sendQueSubCodeSort', //科目排行榜
		oprCount: '/sys/tongji/query', //互动教学操作统计


	},
	platformData: {
		basePlatformData: '/sys/platformData/basePlatformData',
		mapCount: '/sys/platformData/platformStuData', //各地区学生数量
		platformUserRate: '/sys/platformData/platformUserRate', //月使用频率
		platformParTeaUseRate: '/sys/platformData/platformParTeaUseRate', //家长老师使用频率
		platformSchoolUseRate: '/sys/platformData/platformSchoolUseRate', //学校使用频率
		platformSendQueTypeRate: '/sys/platformData/platformSendQueTypeRate', //发题类型
		getOrgGradeId: '/sys/schmessageboard/getOrgGradeId', //查询机构下所有年级

	},
	classboard: {
		getScoreCount: '/sys/pingscore/query'
	}
}


import {
	axios
} from '@/utils/request'

//post
/* export function postAction(url, params, obj = {}) {
	return axios(Object.assign({}, {
		url: url + '?' + QS.stringify(params),
		method: 'post',
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		},
		//data:params
	}, obj))
} */
export function postAction(url, params, obj = {}) {
	return axios(Object.assign({}, {
		url: url,
		method: 'post',
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		},
		data: params
	}, obj))
}
/** 
 * post方法，对应post请求 
 * @param {String} url [请求的url地址] 
 * @param {Object} params [请求时携带的参数] 
 */
export const getAction = (url, params, obj) => {
	return axios(Object.assign({}, {
		url: url,
		method: 'get',
		params: params
	}, obj))
}
export function getDict(type) {
	return postAction(api.getDict, {
		dictType: type
	})
}
export function logout() {
	return postAction(api.logout)
}

export function upLoginCache(orgId) {
	return postAction(sysManageapi.orgUrl.upLoginCache + '?orgId=' + orgId)
}
export function postActionUpload(url, parameter) {
	return axios({
		url: url,
		method: 'post',
		headers: {
			"Content-Type": "multipart/form-data"
		},
		processData: false,
		data: parameter
	})
}
export function postActionExport(url, parameter) {
	return axios({
		url: url,
		method: 'post',
		headers: {
			"Content-Type": "multipart/form-data;charset=UTF-8"
		},
		responseType: 'blob',
		data: parameter
	})
}

export function getMenubyUser() {
	return postAction(sysManageapi.menuUrl.getList)
}
export function setToken(refreshToken) {
	return postAction(api.refreshToken, refreshToken)
}

export function sendWx(sendMsg) {
	return postAction(api.sendWx, sendMsg)
}